import './bootstrap';

import { createApp } from 'vue';
import ElementPlus from 'element-plus'
import zhCn from 'element-plus/dist/locale/zh-cn.mjs'
import * as ElementPlusIconsVue from '@element-plus/icons-vue' // icon图标引入

import { createRouter, createWebHistory } from 'vue-router';
import App from './components/layout/App.vue';
import routes from './routes';

import 'element-plus/dist/index.css'
import 'element-plus/es/components/message/style/css'


const router = createRouter({
    history: createWebHistory(),
    routes
});

// 挂载icon图标
const app = createApp(App);
for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
    app.component(key, component)
}



app.use(router);
app.use(ElementPlus, {
    locale: zhCn,
})

// 定义一个全局前置守卫来检查登录状态，并根据结果执行相应的操作。在这种情况下，我们将使用
// router.beforeEach((to, from, next) => {
//     const isLoggedIn = false; //根据你的逻辑判断用户是否已登录
//     console.log(isLoggedIn, 'isLoggedIn')
//     if (!isLoggedIn && to.path !== '/login') {
//         next('/login');
//     } else {
//         next();
//     }
// });

app.mount('#app');
